import { service } from './service'
import { config } from './config'

const { defaultHeaders } = config

const request = (option) => {
  const { url, method, params, data, headersType, responseType, Authorization } = option
  return service({
    url: url,
    method,
    params,
    data,
    responseType: responseType,
    headers: {
      'content-type': headersType || defaultHeaders
    },
    Authorization
  })
}
export default {
  get: (option) => {
    return request({ method: 'get', ...option })
  },
  post: (option) => {
    return request({ method: 'post', ...option })
  },
  delete: (option) => {
    return request({ method: 'delete', ...option })
  },
  put: (option) => {
    return request({ method: 'put', ...option })
  }
}
